const mysql = require("mysql");
const config = require("./config");
function querySql(sql) {
  const conn = mysql.createConnection(config);
  return new Promise((res, rej) => {
    try {
      conn.query(sql, (err, result) => {
        if (err) {
          rej(err);
        } else {
          res(result);
        }
      });
    } catch (e) {
      rej(e);
    } finally {
      conn.end();
    }
  });
}
module.exports = querySql;
